﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPC.Communication.Reflection
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class HslDeviceAddressAttribute : Attribute
    {
        private Type _deviceType;
        private string _address;
        private int _length;

	    public Type DeviceType
	    {
		    get { return _deviceType; }
		    set { _deviceType = value; }
	    }

	    public string Address
	    {
		    get { return _address; }
	    }

	    public int Length
	    {
		    get { return _length; }
	    }

	    public HslDeviceAddressAttribute(string address)
	    {
		    this._address = address;
		    this._length = -1;
		    this._deviceType = null;
	    }

	    public HslDeviceAddressAttribute(string address, Type deviceType)
	    {
		    this._address = address;
		    this._length = -1;
		    this._deviceType = deviceType;
	    }

	    public HslDeviceAddressAttribute(string address, int length)
	    {
		    this._address = address;
		    this._length = length;
		    this._deviceType = null;
	    }

	    public HslDeviceAddressAttribute(string address, int length, Type deviceType)
	    {
		    this._address = address;
		    this._length = length;
		    this._deviceType = deviceType;
	    }

	    public override string ToString()
	    {
            return String.Format("HslDeviceAddressAttribute[{0}:{1}]", Address, Length);
	    }
    }
}
